/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ManageHelpsPanel.java
 *
 * Created on 18.Kas.2009, 21:16:41
 */

package fairhelper.panels;

import fairhelper.language.Language;
import fairhelper.theme.Theme;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 *
 * @author Feoran
 */
public class ManageHelpsPanel extends javax.swing.JPanel {

    private ManageHelpsMainPanel manageHelpsMainPanel;
    private AddHelpKindPanel addHelpKindpanel;
    private ManageHouseHelpsMainPanel manageHouseHelpsMainPanel;
    private ManagePersonHelpsMainPanel managePersonHelpsMainPanel;
    private UpdateHelpKindPanel updateHelpKindPanel;
    private AddHouseHelpPanel addHouseHelpPanel;
    private AddPersonHelpPanel addPersonHelpPanel;

    /** Creates new form ManageHelpsPanel */
    public ManageHelpsPanel() {
        initComponents();
        manageHelpsMainPanelButtonActionPerformed(null);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        manageHelpsMenuPanel = new javax.swing.JPanel();
        manageHelpsMainPanelButton = new javax.swing.JButton();
        addHelpKindPanelButton = new javax.swing.JButton();
        manageHelpsScrollPane = new javax.swing.JScrollPane();

        setBackground(Theme.getColor("backgroundColor1"));
        setPreferredSize(new java.awt.Dimension(800, 480));

        manageHelpsMenuPanel.setBackground(Theme.getColor("backgroundColor1"));
        manageHelpsMenuPanel.setPreferredSize(new java.awt.Dimension(180, 480));

        manageHelpsMainPanelButton.setBackground(Theme.getColor("backgroundColor2"));
        manageHelpsMainPanelButton.setForeground(Theme.getColor("labelColor1"));
        manageHelpsMainPanelButton.setText(Language.getText("manageHelpsPanelButton"));
        manageHelpsMainPanelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                manageHelpsMainPanelButtonActionPerformed(evt);
            }
        });

        addHelpKindPanelButton.setBackground(Theme.getColor("backgroundColor2"));
        addHelpKindPanelButton.setForeground(Theme.getColor("labelColor1"));
        addHelpKindPanelButton.setText(Language.getText("addHelpKindPanelButton"));
        addHelpKindPanelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addHelpKindPanelButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout manageHelpsMenuPanelLayout = new javax.swing.GroupLayout(manageHelpsMenuPanel);
        manageHelpsMenuPanel.setLayout(manageHelpsMenuPanelLayout);
        manageHelpsMenuPanelLayout.setHorizontalGroup(
            manageHelpsMenuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, manageHelpsMenuPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(manageHelpsMenuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(addHelpKindPanelButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 156, Short.MAX_VALUE)
                    .addComponent(manageHelpsMainPanelButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 156, Short.MAX_VALUE))
                .addContainerGap())
        );
        manageHelpsMenuPanelLayout.setVerticalGroup(
            manageHelpsMenuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(manageHelpsMenuPanelLayout.createSequentialGroup()
                .addGap(107, 107, 107)
                .addComponent(manageHelpsMainPanelButton)
                .addGap(18, 18, 18)
                .addComponent(addHelpKindPanelButton)
                .addContainerGap(305, Short.MAX_VALUE))
        );

        manageHelpsScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(manageHelpsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 608, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(manageHelpsMenuPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(manageHelpsMenuPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(manageHelpsScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void manageHelpsMainPanelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_manageHelpsMainPanelButtonActionPerformed
        addHelpKindpanel = null;
        manageHouseHelpsMainPanel = null;
        managePersonHelpsMainPanel = null;
        manageHelpsMainPanel = new ManageHelpsMainPanel();
        manageHelpsScrollPane.setViewportView(manageHelpsMainPanel);
        manageHelpsScrollPane.revalidate();
        manageHelpsScrollPane.repaint();
        manageHelpsMainPanel.getHelpHouseButton().addActionListener(new ManageHelpsMainPanelHouseHelpButton());
        manageHelpsMainPanel.getHelpPersonButton().addActionListener(new ManageHelpsMainPanelPersonHelpButton());
    }//GEN-LAST:event_manageHelpsMainPanelButtonActionPerformed

    private void addHelpKindPanelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addHelpKindPanelButtonActionPerformed
        manageHelpsMainPanel = null;
        manageHouseHelpsMainPanel = null;
        managePersonHelpsMainPanel = null;
        addHelpKindpanel = new AddHelpKindPanel();
        manageHelpsScrollPane.setViewportView(addHelpKindpanel);
        manageHelpsScrollPane.revalidate();
        manageHelpsScrollPane.repaint();
    }//GEN-LAST:event_addHelpKindPanelButtonActionPerformed

    private class ManageHelpsMainPanelHouseHelpButton implements ActionListener {

        public void actionPerformed(ActionEvent e) {
            manageHelpsMainPanel = null;
            addHelpKindpanel = null;
            managePersonHelpsMainPanel = null;
            manageHouseHelpsMainPanel = new ManageHouseHelpsMainPanel();
            manageHelpsScrollPane.setViewportView(manageHouseHelpsMainPanel);
            manageHelpsScrollPane.revalidate();
            manageHelpsScrollPane.repaint();
            manageHouseHelpsMainPanel.getBackbutton().addActionListener(new ManageHelpsMainPanelBackButton());
            manageHouseHelpsMainPanel.getUpdateHelpTypeButton().addActionListener(new UpdateHouseHelpTypePanelButton());
            manageHouseHelpsMainPanel.getHelpToButton().addActionListener(new HelpToHousesPanelButton());
        }

    }

    private class ManageHelpsMainPanelPersonHelpButton implements ActionListener {

        public void actionPerformed(ActionEvent e) {
            manageHelpsMainPanel = null;
            addHelpKindpanel = null;
            manageHouseHelpsMainPanel = null;
            managePersonHelpsMainPanel = new ManagePersonHelpsMainPanel();
            manageHelpsScrollPane.setViewportView(managePersonHelpsMainPanel);
            manageHelpsScrollPane.revalidate();
            manageHelpsScrollPane.repaint();
            managePersonHelpsMainPanel.getBackButton().addActionListener(new ManageHelpsMainPanelBackButton());
            managePersonHelpsMainPanel.getUpdateHelpPanelButton().addActionListener(new UpdatePersonHelpTypePanelButton());
            managePersonHelpsMainPanel.getHelpToButton().addActionListener(new HelpToPeoplePanelButton());
        }

    }

    private class UpdateHouseHelpTypePanelButton implements ActionListener {

        public void actionPerformed(ActionEvent e) {
            manageHelpsMainPanel = null;
            addHelpKindpanel = null;
            managePersonHelpsMainPanel = null;
            updateHelpKindPanel = new UpdateHelpKindPanel(manageHouseHelpsMainPanel.getSelectedHelp());
            manageHouseHelpsMainPanel = null;
            manageHelpsScrollPane.setViewportView(updateHelpKindPanel);
            manageHelpsScrollPane.revalidate();
            manageHelpsScrollPane.repaint();
        }

    }

    private class UpdatePersonHelpTypePanelButton implements ActionListener {

        public void actionPerformed(ActionEvent e) {
            manageHelpsMainPanel = null;
            addHelpKindpanel = null;
            manageHouseHelpsMainPanel = null;
            updateHelpKindPanel = new UpdateHelpKindPanel(managePersonHelpsMainPanel.getSelectedHelp());
            managePersonHelpsMainPanel = null;
            manageHelpsScrollPane.setViewportView(updateHelpKindPanel);
            manageHelpsScrollPane.revalidate();
            manageHelpsScrollPane.repaint();
        }

    }

    private class HelpToHousesPanelButton implements ActionListener {

        public void actionPerformed(ActionEvent e) {
            manageHelpsMainPanel = null;
            addHelpKindpanel = null;
            managePersonHelpsMainPanel = null;
            addHouseHelpPanel = new AddHouseHelpPanel(manageHouseHelpsMainPanel.getSelectedHelp());
            manageHouseHelpsMainPanel = null;
            manageHelpsScrollPane.setViewportView(addHouseHelpPanel);
            manageHelpsScrollPane.revalidate();
            manageHelpsScrollPane.repaint();
        }

    }

    private class HelpToPeoplePanelButton implements ActionListener {

        public void actionPerformed(ActionEvent e) {
            manageHelpsMainPanel = null;
            addHelpKindpanel = null;
            manageHouseHelpsMainPanel = null;
            addPersonHelpPanel = new AddPersonHelpPanel(managePersonHelpsMainPanel.getSelectedHelp());
            managePersonHelpsMainPanel = null;
            manageHelpsScrollPane.setViewportView(addPersonHelpPanel);
            manageHelpsScrollPane.revalidate();
            manageHelpsScrollPane.repaint();
        }

    }

    private class ManageHelpsMainPanelBackButton implements ActionListener {

        public void actionPerformed(ActionEvent e) {
            manageHelpsMainPanelButtonActionPerformed(null);
        }

    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addHelpKindPanelButton;
    private javax.swing.JButton manageHelpsMainPanelButton;
    private javax.swing.JPanel manageHelpsMenuPanel;
    private javax.swing.JScrollPane manageHelpsScrollPane;
    // End of variables declaration//GEN-END:variables

}
